<div class="form-group">
    <label class="col-sm-2 control-label">[title]</label>
    <div class="col-sm-7">
        <input class="form-control" type="hidden" name="[name]" value="{$info['[name]']|default=''}"/>
        <a href="{$info['[name]']|default='__STATIC__/default.png'}" target="_blank">
            <input class="form-control [name]" value="{$info['[name]']|default=''}" style="width: 50%;display:inline"/>
        </a>
        <button type="button" class="layui-btn" id="[name]">
            <i class="layui-icon">&#xe67c;</i>上传文件
        </button>
    </div>
</div>

<script>
    $(function () {
        layui.use('upload', function(){
            var upload = layui.upload;

            var nameDom = "[name]";
            //执行实例
            upload.render({
                elem: "#"+nameDom //绑定元素
                ,url: "{:url('File/store')}" //上传接口
                ,accept:"file"
                ,done: function(res){
                    //上传完毕回调
                    $('#'+nameDom).parent().find('input[name*='+nameDom+']').val(res.data.saveName);
                    $('#'+nameDom).parent().find('a').attr('href', res.data.saveName);
                    $('.'+nameDom).val(res.data.saveName);
                    // $('#'+nameDom).parent().find('a').text("点击预览");
                }


            });
        });
    })

</script>